package com.windward.vii.dao.mapper;

import com.windward.vii.dao.entity.GiftRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface GiftRecordMapper {
    @Delete({
        "delete from gift_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into gift_record (id, chat_id, ",
        "sender_uid, receiver_uid, ",
        "gift_id, gift_name, ",
        "gift_coin, create_time, ",
        "source_type)",
        "values (#{id,jdbcType=BIGINT}, #{chatId,jdbcType=BIGINT}, ",
        "#{senderUid,jdbcType=BIGINT}, #{receiverUid,jdbcType=BIGINT}, ",
        "#{giftId,jdbcType=BIGINT}, #{giftName,jdbcType=VARCHAR}, ",
        "#{giftCoin,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{sourceType,jdbcType=TINYINT})"
    })
    int insert(GiftRecord record);

    int insertSelective(GiftRecord record);

    @Select({
        "select",
        "id, chat_id, sender_uid, receiver_uid, gift_id, gift_name, gift_coin, create_time, ",
        "source_type",
        "from gift_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    GiftRecord selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(GiftRecord record);

    @Update({
        "update gift_record",
        "set chat_id = #{chatId,jdbcType=BIGINT},",
          "sender_uid = #{senderUid,jdbcType=BIGINT},",
          "receiver_uid = #{receiverUid,jdbcType=BIGINT},",
          "gift_id = #{giftId,jdbcType=BIGINT},",
          "gift_name = #{giftName,jdbcType=VARCHAR},",
          "gift_coin = #{giftCoin,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "source_type = #{sourceType,jdbcType=TINYINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(GiftRecord record);
}